var USER_INFO = 'userInfo'; //用户信息
var USER_NUM = 'num';
var DATE='date';

var IP = 'localhost:8080';
var BASE_URL = 'http://' + IP + '/'; //BASEURL
var BASE_URL_UPLOAD = 'http://' + IP + '/'; //BASEURL

var header = {
  'Accept': 'application/json',
  'content-type': 'application/x-www-form-urlencoded',
  'from': 'micro',
}
/**
 * 设置用户
 */
function setUserInfo(userInfo, cb) {
  wx.setStorage({
    key: USER_INFO,
    data: userInfo,
    success: function (res) {
      typeof cb == "function" && cb(true)
    },
    fail: function (res) {
      typeof cb == "function" && cb(false)
    }
  })
}
function getUserInfo() {
  return wx.getStorageSync(USER_INFO)
}
function removeUserInfo() {
  wx.removeStorageSync(DATE)
  wx.removeStorageSync(USER_NUM)
  return wx.removeStorageSync(USER_INFO)
}
function removeNum() {
  return wx.removeStorageSync(USER_NUM)
}
function removeDate() {
  return wx.removeStorageSync(DATE)
}
/**
 * 设置用户坚持天数
 */
function setUserNum(num, cb) {
  wx.setStorage({
    key: USER_NUM,
    data: num,
    success: function (res) {
      typeof cb == "function" && cb(true)
    },
    fail: function (res) {
      typeof cb == "function" && cb(false)
    }
  })
}
function getNum() {
  return wx.getStorageSync(USER_NUM)
}
/**
 * 签到判定
 */
function setDate(date, cb) {
  wx.setStorage({
    key: DATE,
    data: date,
    success: function (res) {
      typeof cb == "function" && cb(true)
    },
    fail: function (res) {
      typeof cb == "function" && cb(false)
    }
  })
}
function getisDate() {
  return wx.getStorageSync(DATE)
}
/**
 * 获得当天的日期
 */
function getDate(){
  return new Date().getFullYear()+'.'+(new Date().getMonth()+1)+'.'+new Date().getDate()
}




module.exports = {
  removeDate:removeDate,
  removeNum:removeNum,
  DATE:DATE,
  getisDate:getisDate,
  setDate,setDate,
  USER_NUM:USER_NUM,
  getDate:getDate,
  removeUserInfo: removeUserInfo,
  setUserInfo: setUserInfo,
  getUserInfo: getUserInfo,
  setUserNum:setUserNum,
  header:header,
  getNum:getNum,
  BASE_URL: BASE_URL,
  BASE_URL_UPLOAD: BASE_URL_UPLOAD,
  login:"user/login",//登录
  userAdd: "user/add",    //用户注册提交
  userUpdate: "user/update",  //修改用户资料s
  userByName:"user/userbyname",//根据名字查用户
  userList: "user/userList", //获取用户列表，同样用于用户登录
  foodList: "food/foodList",   //获取饮食列表
  sportList: "sport/sportList",   //获取运动列表
  foodid:"food/getid",//获得食物id
  sportid:"sport/getid",//获得运动id
  userFoodList: "userfood/userfoodList", //今日饮食列表
  userSportList: "usersport/usersportList", //今日运动列表
  userJianchi:"user/updateJianchi",//打卡天数更新
  userFoodsAdd: "userfood/add",  //增加今日饮食
  userSportAdd: "usersport/add",  //增加今日运动
  userCalorieup:"usercalorie/update",//更新今日卡路里
  userCalorieQurry:"usercalorie/qurry",//查询今日卡路里
  userCalorieList:"usercalorie/calorieList",//查询七日卡路里
  foodsAdd: "food/add", //申请添加一条饮食.
  sportAdd: "sport/add", //申请添加一条运动
}